package com.yannie.smp.dao;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.yannie.smp.model.User;

public class NativeUserDaoImpl implements UserDao {
	
	private SqlSessionFactory sqlSessionFactory;
	
    public NativeUserDaoImpl(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }
	
	@Override
	public User findUserById(int id) throws Exception {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        User user = sqlSession.selectOne("test.findUserById", id);
        sqlSession.close();
        return user;
	}

}
